﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Register Src="../Shared/Header.ascx" TagName="Header" TagPrefix="uc1" %>
<!DOCTYPE html>

<html>
<head runat="server">
    <title>系统查询</title>
    <uc1:Header ID="Header1" runat="server" />
    <script type="text/javascript" language="javascript">
        $(function () {

            $("#LingYKS").combogrid({
                panelWidth: 436,
                panelHeight: 308,
                idField: 'Id',
                textField: 'Name',
                singleSelect: true,                //是否允许选中一行
                pagination: true,                  //分页
                rownumbers: false,                   //行号
                pageSize: 10,                        //每页记录数
                pageList: [10],             //每页记录数列表
                columns: [[
					        { field: 'Name', title: '科室名称', width: 150 }
                            , { field: 'Description', title: '描述', width: 265 }
				        ]],
                delay: 500,
                mode: 'remote'
            });

            $("#BaoMC").combogrid({
                panelWidth: 436,
                panelHeight: 308,
                idField: 'Id',
                textField: 'Name',
                singleSelect: true,                //是否允许选中一行
                pagination: true,                  //分页
                rownumbers: false,                   //行号
                pageSize: 10,                        //每页记录数
                pageList: [10],             //每页记录数列表
                columns: [[
					        { field: 'Name', title: '包名称', width: 150 }
                            , { field: 'Description', title: '描述', width: 265 }
				        ]],
                delay: 500,
                mode: 'remote'
            });

            $("#LingYR").combogrid({
                panelWidth: 436,
                panelHeight: 308,
                idField: 'Id',
                textField: 'Name',
                singleSelect: true,                //是否允许选中一行
                pagination: true,                  //分页
                rownumbers: false,                   //行号
                pageSize: 10,                        //每页记录数
                pageList: [10],             //每页记录数列表
                columns: [[
					        { field: 'Name', title: '姓名', width: 150 }
                            , { field: 'Description', title: '描述', width: 265 }
				        ]],
                delay: 500,
                mode: 'remote'
            });

            $("#ShiYR").combogrid({
                panelWidth: 436,
                panelHeight: 308,
                idField: 'Id',
                textField: 'Name',
                singleSelect: true,                //是否允许选中一行
                pagination: true,                  //分页
                rownumbers: false,                   //行号
                pageSize: 10,                        //每页记录数
                pageList: [10],             //每页记录数列表
                columns: [[
					        { field: 'Name', title: '姓名', width: 150 }
                            , { field: 'Description', title: '描述', width: 265 }
				        ]],
                delay: 500,
                mode: 'remote'
            });

        });

        function reset() {
            $("#LingYKS").combogrid("setValue", "");
            $("#BaoMC").combogrid("setValue", "");
            $("#LingYR").combogrid("setValue", "");
            $("#ShiYR").combogrid("setValue", "");
            $("#d_begin").datebox("setValue", "");
            $("#d_end").datebox("setValue", "");
        }

        var hasquery = false;
        function submit() {
            var strLingYKS = $("#LingYKS").combogrid("getValue");
            var strBaoMC = $("#BaoMC").combogrid("getValue");
            var strLingYR = $("#LingYR").combogrid("getValue");
            var strShiYR = $("#ShiYR").combogrid("getValue");
            var strBegin = $("#d_begin").datebox("getValue");
            var strEnd = $("#d_end").datebox("getValue");

            if (strBegin != "" && strEnd != "") {
                var begin = strBegin.replace("-", "").replace("-", "");
                var end = strEnd.replace("-", "").replace("-", "");
                if (parseInt(begin) > parseInt(end)) {
                    $.messager.alert('提示', '起始日期不能大于结束日期！', "info");
                    return;
                }
            }

            if (!hasquery) {

                $('#grid').css("display", "");
                $('#grid').datagrid({
                    iconCls: 'icon-save',
                    nowrap: false,                      //设置为true，当数据长度超出列宽时将会自动截取
                    striped: true,                      //奇偶行使用不同背景色
                    url: '/Query/LoadIndex1/',   //从远程站点请求数据的 URL
                    fitColumns: true,                   //适应表格的宽度并且防止水平滚动
                    fit: true,
                    idField: 'Id',                      //标识字段
                    remoteSort: false,                  //定义是否从服务器给数据排序
                    singleSelect: true,                 //是否允许选中一行
                    pagination: true,                  //分页
                    rownumbers: true,                    //行号  
                    pageSize: 20,                        //每页记录数
                    pageList: [10, 20, 30],             //每页记录数列表  
                    queryParams: { LingYKS: strLingYKS, BaoMC: strBaoMC, LingYR: strLingYR, ShiYR: strShiYR, BeginDate: strBegin, EndDate: strEnd }
                });
                hasquery = true;
            }
            else {
                var queryParams = $('#grid').datagrid('options').queryParams;
                queryParams.LingYKS = strLingYKS;
                queryParams.BaoMC = strBaoMC;
                queryParams.LingYR = strLingYR;
                queryParams.ShiYR = strShiYR;
                queryParams.BeginDate = strBegin;
                queryParams.EndDate = strEnd;

                $('#grid').datagrid("options").queryParams = queryParams;
                $('#grid').datagrid("load");
            }
            $('#grid').datagrid({ 
                onLoadSuccess: function () {
                    $('#btnExport').linkbutton({ disabled: false });
                } 
            });
        }

        function exportData() {
            window.location.href = "/Query/ExportData";
        }
    </script>
</head>
<body class="easyui-layout">
    <div id="north_Index1" region="north" style="padding:5px;" border="false"> 
        <table style="width:100%; background-color:#EFEFEF; font-size:12px;" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td colspan="6" style="border-bottom:1px solid #CCCCCC; line-height:2;"><span style="padding-left:10px;">请输入你要查询的条件：</span></td>
                <td style="border-bottom:1px solid #CCCCCC;">
                    
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 80px;padding-top:2px;">领用科室：</td>
                <td style="text-align: left; width: 142px;padding-top:2px;">
                    <select type="text" name="LingYKS" id="LingYKS" style="width:140px;" url="/Package/GetOffices/" idField="Id" textField="Name" />
                </td>
                <td style="text-align: right; width: 80px;">领用人：</td>
                <td style="text-align: left; width: 142px;">
                    <select type="text" name="LingYR" id="LingYR" style="width:140px;" url="/Package/GetRecipients/" idField="Id" textField="Name" />
                </td>
                <td style="text-align: right; width: 80px;">开始日期：</td>
                <td style="text-align: left; width: 142px;">
                    <input id="d_begin" type="text" class="easyui-datebox"/></td>
                <td style="text-align:right;"></td>
            </tr>
            <tr>
                <td style="text-align: right; width: 80px;padding:2px 0;">器械包名称：</td>
                <td style="text-align: left; width: 142px;padding:2px 0;">
                    <select type="text" name="BaoMC" id="BaoMC" style="width:140px;" url="/Package/GetPackage/" idField="Id" textField="Name" />
                </td>
                <td style="text-align: right; width: 80px;">使用人：</td>
                <td style="text-align: left; width: 142px;">
                    <select type="text" name="ShiYR" id="ShiYR" style="width:140px;" url="/Package/GetUsers/" idField="Id" textField="Name" />
                </td>
                <td style="text-align: right; width: 80px;">结束日期：</td>
                <td style="text-align: left; width: 142px;">
                    <input id="d_end" type="text" class="easyui-datebox"/>
                </td>
                <td style="padding-left:20px;">   
                    <a id="btnQuery" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="submit()">查询</a>
                    <a id="btnReset" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-redo" plain="true" onclick="reset()">重写</a>
                    <a id="btnExport" href="/Query/ExportData1/" class="easyui-linkbutton" iconcls="icon-save" plain="true" disabled=true>导出</a>                 
                </td>
            </tr>
        </table>                
    </div>
    <div region="center" style="padding: 0 5px 5px 5px;" border="false">        
        <table id="grid" style="display:none">
            <thead>
                <tr>
                    <th field="TiaoMH" width="9%">条码号</th>
                    <th field="BaoMC" width="10%">包名称</th>
                    <th field="LingYKS" width="10%">领用科室</th>
                    <th field="LingYR" width="9%" formatter="lingyrFormatter">领用人</th>
                    <th field="ShiYR" width="9%" formatter="lingyrFormatter">使用人</th>                 
                    <th field="FaFRQ" width="10%">发放日期</th>
                    <th field="FaFSJ" width="8%" formatter="formatDate">发放时间</th>
                    <th field="FaFR" width="9%">发放人</th>
                    <th field="ShiXSJ" width="10%">失效日期</th>
                    <th field="BaoZR" width="9%">包装人</th>
                    <th field="BaoZRQ" width="10%">包装日期</th>
                    <th field="BaoZSJ" width="8%" formatter="formatDate">包装时间</th>
                    <th field="MieJR" width="9%">灭菌人</th>                    
                    <th field="MieJRQ" width="10%">灭菌日期</th>
                    <th field="MieJSJ" width="8%" formatter="formatDate">灭菌时间</th>
                    <th field="HuiSR" width="12%">回收人/清洗人</th>                    
                    <th field="HuiSRQ" width="10%">回收日期</th>
                    <th field="HuiSSJ" width="8%" formatter="formatDate">回收时间</th>  
                    <th field="ZhuangT" formatter="zhuangtFormatter">状态</th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="win" />
</body>
</html>
